/*      > H.Deque - Deque data type header file */

#ifndef __deque_h

#define __deque_h

struct deque
{
        void *head;     /* pointer to head of deque */
        void *tail;     /* pointer to tail of deque */
        int obj_size;   /* size of one element */
};

typedef struct deque *deque;

#define Front 1
#define Back  0

/* General component routines */

deque deq_new (int obj_len);
void deq_free (deque d);
void deq_clear (deque d);
int deq_copy (deque d1, const deque d2);
int deq_equal (const deque d1, const deque d2);
int deq_empty (const deque d);
int deq_size (const deque d);

/* Iterator */

#define STATUS_CONTINUE 0       /* Continue processing */
#define STATUS_STOP     1       /* Stop processing */
#define STATUS_ERROR    (-1)    /* Error - terminate */

int deq_iterate (const deque d, int (*process)(void *));

/* Deque-specific routines */

int deq_add (deque d, int pos, const void *object);
int deq_pop (deque d, int pos);
void *deq_front (const deque d);
void *deq_back (const deque d);

#endif
